#include <iostream>
#include <math.h>
#define N 100

using namespace std;

void readintVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}

void mirror(int array[], int elements){
int i,j, aux;
i=0;
j=elements-1;
while (i<j){
	aux=array[i];
	array[i]=array[j];
	array[j]=aux;
	++i;
	--j;
}
}

int transform_to_base(int array[], int elements, int base){	
int i=0, number=0;
mirror(array, elements);
while (i<elements){
	number+=array[i]*pow(base, i);
	++i;
}
return number;			
}


int main(){
int array[N];
int elements;
int n;
int base;
cout<<"Type the number of digits you want in the number : ";
cin>>elements;
cout<<"Type the digits: "<< endl;
readintVector(array, elements);
cout<<"The number is ";
for(int i=0; i<elements; i++){
	cout<<array[i];}
cout<<endl;
cout<<"Type the base in which you typed the number(between 2 and 9) ";
cin>>base;
cout<<endl;
n=transform_to_base(array,elements, base);
cout<<"The number in base 10 is " << n << " from base "<< base;
cout<<endl;
return 0;
}

